package ar.edu.sccs.entities;

import java.io.Serializable;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import ar.edu.sccs.util.Constants;

public class Dimension implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Object value;
	private int type;
	private boolean semantic;
	private double similarity;
	private double weight;

	@Override
	public String toString() {
		return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
	}

	public Dimension() {
		super();
	}

	/**
	 * 
	 * @param value
	 */
	public Dimension(Object value) {
		super();
		this.value = value;
	}

	/**
	 * @param similarity
	 * @param value
	 */
	public Dimension(double similarity, Object value) {
		super();
		this.similarity = similarity;
		this.value = value;
	}

	/**
	 * @param semantic
	 * @param weight
	 * @param type
	 * @param value
	 */
	public Dimension(boolean semantic, double weight, int type, Object value) {
		super();
		this.semantic = semantic;
		this.weight = weight;
		this.type = type;
		this.value = value;
}
	
	/**
	 * @param type
	 * @param semantic
	 * @param weight
	 */
	public Dimension(int type, boolean semantic, double weight) {
		super();
		this.type = type;
		this.semantic = semantic;
		this.weight = weight;
		if(type != Constants.Dimension.Type.BOOLEAN)
			this.value = "";
	}

	/**
	 * @return the value
	 */
	public Object getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(Object value) {
		this.value = value;
	}

	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}

	/**
	 * @return the semantic
	 */
	public boolean isSemantic() {
		return semantic;
	}

	/**
	 * @param semantic the semantic to set
	 */
	public void setSemantic(boolean semantic) {
		this.semantic = semantic;
	}

	/**
	 * @return the similarity
	 */
	public double getSimilarity() {
		return similarity;
	}

	/**
	 * @param similarity the similarity to set
	 */
	public void setSimilarity(double similarity) {
		this.similarity = similarity;
	}

	/**
	 * @return the weight
	 */
	public double getWeight() {
		return weight;
	}

	/**
	 * @param weight the weight to set
	 */
	public void setWeight(double weight) {
		this.weight = weight;
	}
	
	public void setStringValue(String value) {
		this.value = value;
	}

	public String getStringValue() {
		return this.value == null ? null : this.value.toString();
	}

	public void setBooleanValue(boolean value) {
		this.value = value;
	}

	public boolean getBooleanValue() {
		return this.value == null ? null : ((Boolean) this.value).booleanValue();
	}
}
